import { _decorator, Vec3, v3,sys } from 'cc';
const { ccclass } = _decorator;

@ccclass('Util')
export class Util  {

    static getDistance(start: Vec3, end: Vec3 ) {
        let pos = v3(start.x - end.x, start.y - end.y)
        
        return Math.sqrt(pos.x * pos.x + pos.y *pos.y)
    }

    static getRandmNumber(min:number, max:number):number {
        let range = max - min
        return min + Math.round(Math.random() * range)
    }

    static getLastDeadRoomIndex():number {
        let lastDeadRoomIndex = sys.localStorage.getItem('lastDeadRoomIndex')
        if (lastDeadRoomIndex == null) {
            return -1
        }

        return Number(lastDeadRoomIndex)
    }

    static setLastDeadRoomIndex(index:number) {
        sys.localStorage.setItem('lastDeadRoomIndex', index + '')
    }

}

